/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.azienda.stampe.parametri;

import it.azienda.framework.persistenza.DAOConnectionSingleton;
import java.util.ArrayList;
import javax.faces.model.SelectItem;
import org.hibernate.Session;

/**
 *
 * @author Utente
 */
public class BeanStampaPrenotazioni extends BeanStampa {

    private java.util.Date dataPartenza = new java.util.Date();
    private Long idLinea;
    private SelectItem[] listaLinee;

    /**
     * @return the dataPartenza
     */
    public java.util.Date getDataPartenza() {
        return dataPartenza;
    }

    /**
     * @param dataPartenza the dataPartenza to set
     */
    public void setDataPartenza(java.util.Date dataPartenza) {
        this.dataPartenza = dataPartenza;
    }

    /**
     * @return the idLinea
     */
    public Long getIdLinea() {
        return idLinea;
    }

    /**
     * @param idLinea the idLinea to set
     */
    public void setIdLinea(Long idLinea) {
        this.idLinea = idLinea;
    }

    /**
     * @return the listaLinee
     */
    public SelectItem[] getListaLinee() {
        try {
            String query = "select bean.id, bean.descrizione"
                    + "  from BeanLinea bean"
                    + " order by bean.descrizione";
            Session sessione = DAOConnectionSingleton.newSession();
            ArrayList listaComuni = (ArrayList) sessione.createQuery(query).list();

            listaLinee = new SelectItem[listaComuni.size() + 1];
            listaLinee[0] = new SelectItem(new Long(0), "Linea");
            for (int i = 0; i < listaComuni.size(); i++) {
                Object[] obj = (Object[]) listaComuni.get(i);
                listaLinee[i + 1] = new SelectItem(new Long(obj[0].toString()), obj[1].toString());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        return listaLinee;
    }

    /**
     * @param listaLinee the listaLinee to set
     */
    public void setListaLinee(SelectItem[] listaLinee) {
        this.listaLinee = listaLinee;
    }

}
